package com.lemote.entity;

import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

/**
 * 
 * 
 * 
 * 
 * @author slaton.wu@gmail.com
 * @version 1.0
 * @created 2011-7-31 下午09:55:23
 */
@Entity
@Table(name = "smt_PackageBox")
// 默认的缓存策略.
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class PackageBox extends IdEntity {

	private String boxNo;

	private OrderEntity orderEntity;

	private Date createTime;

	private Integer num;

	private Integer maxNum;
	
	private User packer;
	
	private List<CircuitBoard> boards;
	
	
	@OneToMany(mappedBy = "box", cascade = { CascadeType.PERSIST}, fetch = FetchType.LAZY, targetEntity = CircuitBoard.class)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	public List<CircuitBoard> getBoards() {
		return boards;
	}

	public void setBoards(List<CircuitBoard> boards) {
		this.boards = boards;
	}

	@ManyToOne
	@JoinColumn(name="packer")
	public User getPacker() {
		return packer;
	}

	
	public void setPacker(User packer) {
		this.packer = packer;
	}

	public String getBoxNo() {
		return boxNo;
	}

	public void setBoxNo(String boxNo) {
		this.boxNo = boxNo;
	}

	@ManyToOne
	@JoinColumn(name="orderId")
	public OrderEntity getOrderEntity() {
		return orderEntity;
	}

	public void setOrderEntity(OrderEntity orderEntity) {
		this.orderEntity = orderEntity;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Integer getNum() {
		return num;
	}

	public void setNum(Integer num) {
		this.num = num;
	}

	public Integer getMaxNum() {
		return maxNum;
	}

	public void setMaxNum(Integer maxNum) {
		this.maxNum = maxNum;
	}

}
